package com.dawn.trademanage.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import com.dawn.trademanage.bean.TradeInfoBean;

@Repository
public class TradeManageDao {

    @Autowired
    private HibernateTemplate hibernateTemplate;

    public void addTrade(TradeInfoBean tradeInfo) {
            hibernateTemplate.save(tradeInfo);
    }

    public List<TradeInfoBean> showTradeList() {
        List<TradeInfoBean> tradeList;
        tradeList = (List<TradeInfoBean>) hibernateTemplate.find("from TradeInfoBean");
        return tradeList;
    }
    
    public List<TradeInfoBean> findTradeById(int tradeId) {
        List<TradeInfoBean> tradeList;
        tradeList = (List<TradeInfoBean>) hibernateTemplate.find("from TradeInfoBean tb where tb.tradeId = ?",tradeId);
        return tradeList;
    }

}
